package com.ls.fw.data.config;

import java.util.Properties;

public abstract class DataConfigAdapter implements DataConfig{

	@Override
	public String getPriKeyName() { 
		Properties pro = this.getProperties();
		if(pro != null){
			return pro.getProperty(PARAM_PRIKEYNAME, DEFAULT_ID);
		}
		return DEFAULT_ID;
	}


	@Override
	public void put(String name, Object value){
		Properties pro = this.getProperties();
		if(pro != null){
			pro.put(name, value);
		}
	}
	
	
	@Override
	public String get(String name){
		Properties pro = this.getProperties();
		if(pro != null){
			return pro.getProperty(name);
		}
		return "";
	}
	
	
	@Override
	public Object remove(String name){
		Properties pro = this.getProperties();
		if(pro != null){
			return pro.remove(name);
		}
		return "";
	}
	
	
	@Override
	public boolean containsKey(String name){
		Properties pro = this.getProperties();
		if(pro != null){
			return pro.containsKey(name);
		}
		return false;
	}
	
	
	@Override
	public String get(String name, String defaultValue){
		Properties pro = this.getProperties();
		if(pro != null){
			return pro.getProperty(name,defaultValue);
		}
		return defaultValue;
	}


	@Override
	public boolean isAutoCommit() {
		return Boolean.parseBoolean(this.get(PARAM_AUTOCOMMIT,"false"));
	}


	@Override
	public String getAddress() {
		return this.get(PARAM_ADDRESS,"");
	}
	
	@Override
	public String getServerName(){
		return this.get(PARAM_NAME,"");
	}
}
